---
title: "Table 3 and tables in Online appendix V"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Note

The code in "ecolRxC_accuracy_Thomsen_probit_no_aprox.html" must be previously run for this code to run. The package *tidyverse* is needed for this code to run.

## Introduction

This document contains the code to replicate Table 3 in the paper and the figures in the tables in Online appendix V.

### Reproducible code for data in Table 3
```{r}
library(tidyverse)
datos <- read.csv("summary_ecolRxC_solutions_Thomsen_probit_FALSE.csv", sep =";",
                  stringsAsFactors = F)

EI.errors <- datos %>% select(year, EI.ecolRxC.Mean:EI.ecolRxC.LSQRM) %>% 
  group_by(year) %>% summarise(across(everything(), mean, na.rm = TRUE))

NZ.SCO <-  datos %>% select(EI.ecolRxC.Mean:EI.ecolRxC.LSQRM) %>%
  summarise(across(everything(), mean, na.rm = TRUE))
NZ.SCO <- cbind(year = "NZ+SCO", NZ.SCO)

EI.errors <- rbind(EI.errors, NZ.SCO)
write.table(EI.errors, "EI_composite.csv", sep = ";", row.names = FALSE)
```

### Reproducible code for data in Online appendix V
```{r}
# EPW
EPW.errors <- datos %>% select(year, EPW.ecolRxC.Mean:EPW.ecolRxC.LSQRM) %>% 
  group_by(year) %>% summarise(across(everything(), mean, na.rm = TRUE))

NZ.SCO <-  datos %>% select(EPW.ecolRxC.Mean:EPW.ecolRxC.LSQRM) %>%
  summarise(across(everything(), mean, na.rm = TRUE))
NZ.SCO <- cbind(year = "NZ+SCO", NZ.SCO)

EPW.errors <- rbind(EPW.errors, NZ.SCO)

write.table(EPW.errors, "EPW_composite.csv", sep = ";", row.names = FALSE)


# EQ
EQ.errors <- datos %>% select(year, EQ.ecolRxC.Mean:EQ.ecolRxC.LSQRM) %>% 
  group_by(year) %>% summarise(across(everything(), mean, na.rm = TRUE))

NZ.SCO <-  datos %>% select(EQ.ecolRxC.Mean:EQ.ecolRxC.LSQRM) %>%
  summarise(across(everything(), mean, na.rm = TRUE))
NZ.SCO <- cbind(year = "NZ+SCO", NZ.SCO)

EQ.errors <- rbind(EQ.errors, NZ.SCO)

write.table(EQ.errors, "EQ_composite.csv", sep = ";", row.names = FALSE)


```

